#include "p_3_2.h"
#include <iostream>

using namespace std;


char c[10][10] = {
	"",
	"",
	"ABC",
	"DEF",
	"GHI",
	"JKL",
	"MNO",
	"PQRS",
	"TUV",
	"WXYZ",
};

int total[10] = {0,0,3,3,3,3,3,4,3,4};
int number[tel_len] = {5,4,3,2,1};
int answer[tel_len];
void tel_search(int* num,int* answer,int n){
	while (true){
		for (int i = 0;i < n;++i)
			cout<<c[num[i]][answer[i]];
		cout<<endl;
		int k = n - 1;
		while (k >= 0){
			if (answer[k] < total[num[k]] - 1){
				++answer[k];
				break;
			}
			else {
				answer[k] = 0;
				--k;
			}
		}

		if (k < 0)
			break;
	}
}

void recursive_tel_search(int* num,int* answer,int index,int n){
	if (index == 0){
		for (int i = 0;i < n;++i)
			cout<<c[num[i]][answer[i]];
		cout<<endl;
		return;
	}
	for (answer[index] = 0;answer[index] < total[num[index]]; ++answer[index]){
		recursive_tel_search(num,answer,index-1,n);
	}
}
